package com.budwk.app.sqfwV2.enums;

import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwV2.generator.entrepreneurShipHouse.DrivingEmploymentSituationExcel;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * 创业实体入户
 */
@Getter
public enum EntrepreneurHouseFileEnum {

    ONE_EXCEL("employment_promotion_situation_leger", new DrivingEmploymentSituationExcel(), "sqfwV2/entrepreneurHouse/drivingEmploymentSituationExcel.xlsx"),
    ONE_PDF("employment_promotion_situation_doc", null, "sqfwV2/entrepreneurHouse/householdSurveyFormDoc.docx");

    private final String code;

    private final BaseTemplateExcelGenerator service;

    private final String filePath;

    EntrepreneurHouseFileEnum(String code, BaseTemplateExcelGenerator service, String filePath) {
        this.code = code;
        this.service = service;
        this.filePath = filePath;
    }

    public static List<EntrepreneurHouseFileEnum> getAllExcel() {
        return List.of(ONE_EXCEL);
    }

    public static List<EntrepreneurHouseFileEnum> getAllPdf() {
        return List.of(ONE_PDF);
    }

    /**
     * @param code
     * @return
     */
    public static BaseTemplateExcelGenerator getService(String code) {
        Optional<EntrepreneurHouseFileEnum> optional = Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst();
        return optional.map(EntrepreneurHouseFileEnum::getService).orElse(null);
    }
}
